package com.ato.java;

/**
 * @author wangjing
 * @create 2021--06--08--21:18
 */
public class ArrayTest3 {

    public static void main(String[] args){
        int[] arr1 , arr2;
        arr1 = new int[]{2,3,5,7,11,13,17,19};
        System.out.println("开始的arr1");
        for (int i =0 ; i<arr1.length;i++){
            System.out.print(arr1[i]+"---");
        }
//        赋值arr2= arr1
        arr2= arr1; // 结论：修改了数组arr2的内存中的地址 和arr1也一样。那么修改arr2后。arr1也变了。都是指向的同一个内存
//        修改arr1
        for (int y =0;y<arr2.length;y++){
            if( y%2==0){
                arr2[y]=y;
                System.out.println(arr2[y]);
            }
        }
//        在打印arr1
        System.out.println("现在的arr1");

        for (int i =0 ; i<arr1.length;i++){
            System.out.print(arr1[i]+"---");
        }
        System.out.println("\n");
//        真正的复制
        int[] arr3 = new int[arr1.length];
        for (int x = 0 ; x<arr3.length ;x++){

            arr3[x] =arr1[x];
            System.out.print(arr3[x]+"------");
        }

    }
}
